var riskWarningCtrl  = new XFApp.client();

XFApp.client.prototype.riskWarning = {
		successCode : "10000",	
		riskWarningPage : null,
		urlItems : {
			initListURL: basePath+"/riskWarning/init",			
		},
		
		load : function (){
			
            _this = this;            
			
            var qualityRate =  $("#qaRate").val() ;
            var startQARateVal ; 
            var endQARateVal ;
            if(qualityRate == '≤90%'){
            	endQARateVal = 90 ;
            }else if(qualityRate =='90%~95%'){
            	startQARateVal = 90;
            	endQARateVal = 95;
            }else if(qualityRate == '≥95%'){
            	startQARateVal = 95;
            }
            
			var objParams = {				
				customerCode : $("#customerCode").val(),
				customerName : $("#customerName").val(),
				startQARate : startQARateVal ,
				endQARate: endQARateVal,
			}
			
			if(!!_this.riskWarningPage){
				_this.riskWarningPage.page("remote",0,objParams);
			}else{
				_this.riskWarningPage = $("#page").page({
				pageSize : 10,
				remote: {
					url: _this.urlItems.initListURL,
			        params: objParams, 
			        success: function (data, pageIndex) {
			        	if(data.code==_this.successCode){			        		
			        		if(null == data 
									|| null == data.result 
										|| null == data.result.itemList
											|| data.result.itemList.length < 1
												|| data.result.itemList[0].customerCode == null){
			        			$("#data_grid").html('<tr><td align="center" colspan="11">暂无数据</td></tr>');
			        		}else{
			        			$("#data_grid").html($("#dataTmp").render(data.result.itemList));
			        		}			        		
			        	}else{
			        		window.webDialogUtil.alert("提示",data.msg);			        		   
			        	}
			        },
			        error : function(){			        	
			        	window.webDialogUtil.alert("提示","数据查询失败!");			      	  
			        }
				},
				firstBtnText : '首页',
				lastBtnText : '尾页',
				prevBtnText : '上一页',
				nextBtnText : '下一页',
				showInfo : true,
				showJump : true,
				jumpBtnText : '跳转',
				showPageSizes : true,
				infoFormat : '共{pageCount}页'
			});	
		   }			
		},
		
		initSelect : function (){
			
			$("#qaRate").bsSuggest({
				idField: "index",  
				keyField: "description",
				effectiveFields :["index","description"],
				effectiveFieldsAlias:{index:"编码",description:"名称"},
		        data: {
		           'value': qualityRate
		        }
		   });
			
		},
		
		event : function(){
			_this = this;
			
			$("#btnSearch").on("click",function(){
				_this.load();
			});
			
			$("#btnReset").on("click",function(){
				$("#customerCode").val("");
				$("#customerName").val("");
				$("#qaRate").val("");
				$("#qaRate").attr("data-id","");
			});
		},
			
		
};


$(function(){
	riskWarningCtrl.riskWarning.load();
	riskWarningCtrl.riskWarning.event();
	riskWarningCtrl.riskWarning.initSelect();
});